			$(document).ready(function() {
				if("undefined" != typeof userId){
					gebo_init.storeUserInfo(userId);
					if("undefined" != typeof sidebarDatas){
						gebo_init.storeSidebarDatas(userId,sidebarDatas);
					}
					if("undefined" != typeof navDatas){
						gebo_init.storeNavDatas(userId,navDatas);
					}
				}
				if("undefined" != typeof breadCrumbDatas){
					gebo_init.loadBreadCrumbDatas(breadCrumbDatas);
				}
				if("undefined" != typeof tabDatas){
					gebo_init.loadTabDatas(tabDatas);
				}
				gebo_init.loadSidebarDatas();
				gebo_init.loadNavDatas();
				gebo_init.loadStyleSwitcher();
				gebo_init.autoHeaderNavSize();
				//* style switcher
				gebo_style_sw_plus.init();
				gebo_style_sw_plus.restore();
			});
			gebo_init = {
				autoHeaderNavSize: function(){
			      //pc:42px(常规) 78px(宽屏两行) 124px(纯平两行)
			      //phone:206px(?常规-腾讯浏览器) 124px(常规-android原生浏览器)
			      var navHeight = $("header div.navbar").height();
			      if(navHeight<75){
			    	  $("#contentwrapper").css("margin-top","10px");
			    	  $("#sidebar").css("top","10px");
			    	  $(".sidebar_switch").css("top","50px");
			      }
			      if(navHeight >75 && navHeight <120 ){
			          //$("#contentwrapper").css("margin-top","37px");
			          //$("#sidebar").css("margin-top","37px");
			          //$(".sidebar_switch").css("top","80px");
			      }else
			      if( navHeight >120 ){
			          //$("#contentwrapper").css("margin-top","75px");
			          //$("#sidebar").css("margin-top","80px");
			          //$(".sidebar_switch").css("top","125px");
			      }
				},
			    storeUserInfo: function(userId){
			    	amplify.store.sessionStorage("userId",userId);
			    },
				storeSidebarDatas: function(userId,datas) {
					var ordered_datas = TAFFY(datas)().order("id").get();
					amplify.store.sessionStorage( "sidebarDatas"+userId,ordered_datas );
				},
				storeNavDatas: function(userId,datas) {
					var ordered_datas = TAFFY(datas)().order("id").get();
					amplify.store.sessionStorage( "navDatas"+userId,ordered_datas );
				},
				loadSidebarDatas: function(){
					var stored_userId = amplify.store.sessionStorage( "userId" );
					var stored_sidebarDatas = amplify.store.sessionStorage( "sidebarDatas"+stored_userId );
					amplify.publish("buildSidebar",stored_sidebarDatas);
				},
				loadNavDatas: function(){
					var stored_userId = amplify.store.sessionStorage( "userId" );
					var stored_navDatas = amplify.store.sessionStorage( "navDatas"+stored_userId );
					amplify.publish("buildNav",stored_navDatas);
				},
				loadBreadCrumbDatas: function(datas){
					var ordered_datas = TAFFY(datas)().order("id").get();
					amplify.publish("buildBreadCrumb",ordered_datas);
				},
				loadTabDatas: function(datas){
					var ordered_datas = TAFFY(datas)().order("id").get();
					amplify.publish("buildTab",ordered_datas);
				},				
				loadStyleSwitcher: function(){
					var styleSwitcher = $(".style_switcher");
					if(styleSwitcher.length>0){
						styleSwitcher.html(document.getElementById('styleSwitcher-template').text);
					}				
				}				
			};		

			//* style switcher
			gebo_style_sw_plus = {
				init: function() {
					if($('.style_switcher').length) {
						$('body').append('<a class="ssw_trigger" href="javascript:void(0)"><i class="icon-cog icon-white"></i></a>');
						var defLink = $('#link_theme').clone();
						
						
						$('input[name=ssw_sidebar]:first,input[name=ssw_layout]:first,input[name=ssw_menu]:first').attr('checked', true);
						
						$(".ssw_trigger").click(function(){
							$(".style_switcher").toggle("fast");
							$(this).toggleClass("active");
							return false;
						});
						
						// colors
						$('.style_switcher .jQclr').click(function() {
							$(this).closest('div').find('.style_item').removeClass('style_active');
							$(this).addClass('style_active');
							var style_selected = $(this).attr('title');
							$('#link_theme').attr('href','css/'+style_selected+'.css');
							$.cookie('style_switcher_colors', style_selected, {expires:365});
						});
						
						// backgrounds
						$('.style_switcher .jQptrn').click(function(){
							$(this).closest('div').find('.style_item').removeClass('style_active');
							$(this).addClass('style_active');
							var style_selected = $(this).attr('title');
							if($(this).hasClass('jQptrn')) { $('body').removeClass('ptrn_a ptrn_b ptrn_c ptrn_d ptrn_e').addClass(style_selected); };
							$.cookie('style_switcher_backgrounds', style_selected, {expires:365});
						});
						//* layout
						$('input[name=ssw_layout]').click(function(){
							var layout_selected = $(this).val();
							$('body').removeClass('gebo-fixed').addClass(layout_selected);
							$.cookie('style_switcher_layout', layout_selected, {expires:365});
						});
						//* sidebar position
						$('input[name=ssw_sidebar]').click(function(){
							var sidebar_position = $(this).val();
							$('body').removeClass('sidebar_right').addClass(sidebar_position);
							$(window).resize();
							$.cookie('style_switcher_sidebarPosition', sidebar_position, {expires:365});
						});
						//* menu show
						$('input[name=ssw_menu]').click(function(){
							var menu_show = $(this).val();
							$('body').removeClass('menu_hover').addClass(menu_show);
							$.cookie('style_switcher_menuShow', menu_show, {expires:365});
						});
						
						//* reset
						$('#resetDefault').click(function(){
							$('body').attr('class', '');
							$('.style_item').removeClass('style_active').filter(':first-child').addClass('style_active');
							$('#link_theme').replaceWith(defLink);
							$('.ssw_trigger').removeClass('active');
							$(".style_switcher").hide();
							
							$.cookie('style_switcher_colors', 'blue', {expires:365});
							$.cookie('style_switcher_backgrounds', '', {expires:365});
							$.cookie('style_switcher_layout', '', {expires:365});
							$.cookie('style_switcher_sidebarPosition', '', {expires:365});
							$.cookie('style_switcher_menuShow', '', {expires:365});
							return false;
						});
						
						$('#showCss').on('click',function(e){
							var themeLink = $('#link_theme').attr('href'),
								bodyClass = $('body').attr('class');
							var contentStyle = '';
							contentStyle = '<div style="padding:20px;background:#fff">';
							if( (themeLink != 'css/blue.css') && (themeLink != undefined) ) {
								contentStyle += '<div class="sepH_c"><textarea style="height:20px" class="span5">&lt;link id="link_theme" rel="stylesheet" href="'+themeLink+'"&gt;</textarea><span class="help-block">Find stylesheet with id="link_theme" in document head and replace it with this code.</span></div>';
							}
							if( (bodyClass != '') && (bodyClass != undefined) ) {
								contentStyle += '<textarea style="height:20px" class="span5">&lt;body class="'+$('body').attr('class')+'"&gt;</textarea><span class="help-block">Replace body tag with this code.</span>';
							} else {
								contentStyle += '<textarea style="height:20px" class="span5">&lt;body&gt;</textarea>';
							}
							contentStyle += '</div>';
							$.colorbox({
								opacity				: '0.2',
								fixed				: true,
								html				: contentStyle
							});
							e.preventDefault();
						})
					}
				},
				restore: function(){
					var colors = $.cookie('style_switcher_colors');
					var backgrounds = $.cookie('style_switcher_backgrounds');
					var layout = $.cookie('style_switcher_layout');
					var sidebarPosition = $.cookie('style_switcher_sidebarPosition');
					var menuShow = $.cookie('style_switcher_menuShow');
					if(colors!=null){
						$('#link_theme').attr('href','css/'+colors+'.css');
						$('.style_switcher .jQclr').closest('div').find('.style_item').removeClass('style_active');
						$(".style_switcher .jQclr[title='"+colors+"']").addClass('style_active');
					}
					if(backgrounds!=null){
						$('body').removeClass('ptrn_a ptrn_b ptrn_c ptrn_d ptrn_e').addClass(backgrounds);
						$('.style_switcher .jQptrn').closest('div').find('.style_item').removeClass('style_active');
						$(".style_switcher .jQptrn[title='"+backgrounds+"']").addClass('style_active');
					}
					if(layout!=null){
						$('body').removeClass('gebo-fixed').addClass(layout);
						$(".style_switcher input[name='ssw_layout']").removeAttr('checked');
						$(".style_switcher input[name='ssw_layout'][value='"+layout+"']").attr('checked',"checked");
					}
					if(sidebarPosition!=null){
						$('body').removeClass('sidebar_right').addClass(sidebarPosition);
						$(window).resize();	
						$(".style_switcher input[name='ssw_sidebar']").removeAttr('checked');
						$(".style_switcher input[name='ssw_sidebar'][value='"+sidebarPosition+"']").attr('checked',"checked");						
					}
					if(menuShow!=null){
						$('body').removeClass('menu_hover').addClass(menuShow);
						$(".style_switcher input[name='ssw_menu']").removeAttr('checked');
						$(".style_switcher input[name='ssw_menu'][value='"+menuShow+"']").attr('checked',"checked");						
					}
				}
			};			